<template>
	<view class="u-p-b-100">
		<view class="u-flex-col u-col-center u-m-t-50" v-if="list.length==0">
			<u-image src="https://www.sqkjkj.vip/wxImg/1.png" width='100rpx' height='100rpx'></u-image>
			<view class="cl_999 u-font-30 u-m-t-30">暂无收货地址</view>
		</view>
		<view class="u-p-30" v-for="(item,index) in list" :key="index">
			<view class=" u-b-r-20 bg_FFFFFF u-p-30 u-auto ">
				<view class="u-flex u-row-between u-m-t-10 u-font-28">
					<view class="">发货人:{{item.name}}</view>
					<view class="">{{item.phone}}</view>
				</view>

				<view class="u-m-t-30 u-font-24 u-p-b-20">{{item.modify_region.name+'/'+item.addr}}</view>

				<view class="u-p-t-20 u-flex u-row-between" style="border-top: 1rpx solid #D7D7D7;">


					<view class="u-flex">
						<view class="u-flex" @click.stop="change(item)">
							<u-image src='https://www.sqkjkj.vip/wxImg/orderlist/img8.png' width='28rpx' height='28rpx'>
							</u-image>
							<view class="u-m-l-10 u-m-t-10 u-font-20" style="color: #FF5502;">编辑</view>
						</view>
						<view class="u-flex u-m-l-20" @click="remove_addrerss(item.id)">
							<u-image src='https://www.sqkjkj.vip/wxImg/orderlist/img9.png' width='28rpx' height='28rpx'>
							</u-image>
							<view class="u-m-l-10 u-m-t-10 u-font-20" style="color: #FC3533;">删除</view>
						</view>
					</view>

					<view class="u-flex" v-if="item.is_default==1">
						<u-image src='https://www.sqkjkj.vip/wxImg/orderlist/img7.png' width='28rpx' height='28rpx'></u-image>
						<view class="u-m-l-10 u-m-t-10 u-font-22">默认地址</view>
					</view>
				</view>

			</view>
		</view>

		<view class="u-fixed u-w-750 u-b-0 u-z-300 u-p-25 bs_EFEFEF ">
			<view @click="$u.route('/pages/address/addressAll?num=1')"
				class="u-flex u-auto cl_FFF u-flex-col u-col-center u-b-r-20 u-h-98 u-w-640 u-l-h-98"
				style="background:linear-gradient(-64deg, #FF382C, #FF633F);">
				<view class="u-flex">
					<view class="" style="margin-top: -60rpx;">
						<u-image src='https://www.sqkjkj.vip/wxImg/orderlist/jia.png' width='28rpx' height='28rpx'>
						</u-image>
					</view>

					<view class="u-m-l-20">添加新地址</view>
				</view>

			</view>
		</view>
		<!-- 删除模态框 -->
		<u-modal v-model="show" content="确定要删除吗?" :show-cancel-button='true' @confirm='confirm'></u-modal>
	</view>


</template>

<script>
	export default {
		data() {
			return {
				list: [],
				order_id: '',
				show: false,
				addressId:''
			}
		},

		onLoad() {

		},
		onShow() {
			this.massage()
		},
		methods: {
			// 获取收货地址弹窗
			massage() {
				this.$api.my_address_list({}, res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.list = res.data.data.data
						console.log(this.list);
					}
				})
			},
			// 点击编辑地址
			change(obj) {
				uni.setStorageSync("address", obj)
				uni.redirectTo({
					url: '/pages/address/addressAll?num=2'
				})
			},
// 点击删除
			remove_addrerss(id) {
				this.addressId=id
				this.show=true
			},
			confirm(e){
				this.$api.add_delete({id:this.addressId}, res => {
					if (res.data.code == 1) {
						this.massage()
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F9F9F9;
	}
</style>
